package Kuang;

import java.util.ArrayList;
import java.util.List;

/**
 * description:
 * author:zcx
 * lenovo
 * 时间：2022.02.09.20.48
 */
public class Demo15 {

    public static void main(String[] args) {
        List<String> list = new ArrayList<String>();
        for (int i = 0; i < 1000; i++) {
                new Thread(() -> {
                    synchronized (list) {
                        list.add(Thread.currentThread().getName());
                    }
                }).start();
            }
        try {
            Thread.sleep(100);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        System.out.println(list.size());
        }

}
